#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <set>
using namespace std;


class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int maxLen = 0;
        int left = 0,right = 0;//滑动窗口
        map<char,int> char_mem;
        for (; right < s.size(); ++right) {
            if(char_mem.find(s[right])!=char_mem.end()){
                left = max(left,char_mem[s[right]]+1);
            }
            char_mem[s[right]]=right;
            maxLen = max(maxLen,right-left+1);
        }
        return maxLen;
    }
};

int main(){
    Solution a;
}